<!--
 * @FileDescription 毫米波碰撞检测区域设置
 * @Author 杨宇翔
 * @Date 20220531 15:24:25
 * @LastEditors 杨宇翔
 * @LastEditTime 20220531 15:24:25
-->
<template>
    <div class="usage-area">
        <div class="container">
            <div class="header">
                <span>坐标轴设置</span>
                <span class="material-icons"
                    @click="UsageForMillimeterWaveRadarComponent.Default.NavigateToPreviousAsync()">×</span>
            </div>

            <div class="content">
                <div>
                    <span>横轴：</span>
                    <input type="number" v-model.number="UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalX"
                        @blur="OnBlur">
                    <span>至</span>
                    <input type="number" v-model.number="UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalY"
                        @blur="OnBlur">
                </div>
                <div>
                    <span>纵轴：</span>
                    <input type="number" v-model.number="UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalX"
                        @blur="OnBlur">
                    <span>至</span>
                    <input type="number" v-model.number="UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalY"
                        @blur="OnBlur">
                </div>
            </div>

            <div class="button-container">
                <button class="reset colorwhite" type="button"
                    @click="UsageForMillimeterWaveRadarComponent.Default.SubmitAxisAsync">
                    <span>配置</span>
                </button>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import { reactive, ref, toRaw, UnwrapNestedRefs } from 'vue';
import { CollisionComponent, UsageForMillimeterWaveRadarComponent } from './ExamComponent';

function OnBlur(event: FocusEvent): void {
    const element = event.target as HTMLInputElement;
    if (element.value != '') {
        return;
    }

    if (typeof UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalX === 'string' && UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalX == '') {
        UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalX = 0;
    }

    if (typeof UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalY === 'string' && UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalY == '') {
        UsageForMillimeterWaveRadarComponent.Default.AxisData.HorizontalY = 0;
    }

    if (typeof UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalX === 'string' && UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalX == '') {
        UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalX = 0;
    }

    if (typeof UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalY === 'string' && UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalY == '') {
        UsageForMillimeterWaveRadarComponent.Default.AxisData.VerticalY = 0;
    }
}
</script>

<style scoped>
.usage-area {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;

    backdrop-filter: blur(1rem);
}

.container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    width: 80rem;
    height: 36rem;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    border-radius: 2rem;
    border: solid 0.6rem transparent;
    background-image: linear-gradient(#131620, #131620),
        linear-gradient(90deg, #218cde, #807de1);
    background-origin: border-box;
    background-clip: content-box, border-box;
}

.header {
    width: 100%;

    padding: 2rem;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header>span:first-of-type {
    color: white;
    font-size: 2.4rem;
    font-weight: 500;
}

.header>.material-icons {
    color: #81859C;
    font-size: 3.6rem;
}

.content {
    padding-left: 4rem;
    padding-right: 4rem;

    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.content>div {
    display: flex;
    align-items: center;
    gap: 2rem;

    color: #B1B1D4;
    font-size: 1.6rem;
}

input {
    flex-grow: 1;
    /* width: 24rem; */
    height: 3.6rem;

    border: none;
    outline: none;

    color: #B1B1D4;
    font-size: 1.6rem;

    padding-left: 1.5rem;

    background-color: transparent;

    border-radius: 0.6rem;
    border: 0.1rem solid #36384B;
}

input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
    display: none;
}

.button-container {
    width: 100%;

    margin: auto;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4rem;
}

button {
    width: 25rem;
    height: 10rem;

    margin: auto;

    background-image: url('/static/Exam/btn-bg.png');
    background-repeat: no-repeat;
    background-position-y: -0.5rem;
    background-size: cover; 
}

button>span {
    display: inline-block;

    color: white;
    font-size: 3rem;

    text-indent: 1rem;
    letter-spacing: 1rem;
}
</style>